#@layout()

#define main()
<div class="jfa-header-box" id="jfa-header-box">
	<div class="jfa-crumbs" id="jfa-crumbs">
		<a href="#(ctx)/admin/vehicleHistory">周转车历史信息</a> / 条码号: #(barcode??)
	</div>
	#include("/_view/common/_header_right.html")
</div>
<div class="jfa-content-box" id="jfa-content-box">
	<div class="jfa-content" id="jfa-content">
	    <!--<div class="margin-top-30">-->
			<!--<form class="form-horizontal actionPanel" action="#" method="get">-->
		        <!--<div class="row">-->
		             <!--<div class="form-group col-lg-3">-->
		                 <!--<label class="col-sm-3 control-label">挂框</label>-->
		                 <!--<div class="col-sm-9">-->
		                     <!--<input type="text" id="form-rackNo" class="form-control" name="rackNo" value="">-->
		                 <!--</div>-->
		             <!--</div>-->
		             <!--<div class="form-group col-lg-3">-->
		                 <!--<label class="col-sm-4 control-label">跟踪号</label>-->
		                 <!--<div class="col-sm-8">-->
		                     <!--<input type="text" id="form-traceCode" class="form-control" name="traceNo" value="">-->
		                 <!--</div>-->
		             <!--</div>-->
		             <!--<div class="form-group col-lg-4">-->
		                 <!--<label class="col-sm-6 control-label">周转车编号</label>-->
		                 <!--<div class="col-sm-6">-->
		                     <!--<input type="text" id="form-vehicleCode" class="form-control" name="traceNo" value="">-->
		                 <!--</div>-->
		             <!--</div>-->
		             <!--<div class="form-group col-lg-2">-->
                         <!--<div class="col-sm-12">-->
                             <!--<button type="button" class="btn btn-primary" onclick="searchVehicle()">查询</button>-->
                             <!--<button type="reset" class="btn btn-default">重置</button>-->
                         <!--</div>-->
                     <!--</div>-->
		         <!--</div>-->
		    <!--</form>-->
		<!--</div>-->
		

	###	<div id="toolbar" class="btn-group">
	###		<a class="btn btn-primary btn-sm margin-right-10" href="#(ctx)/admin/turnoverVehicle/add" >
	###			<i class="fa fa-plus"></i>
	###			添加周转车信息
	###		</a>
	### </div>
	    
		<table id="turnoverVehicle">
		</table>
	</div>
</div>
<script type="text/javascript">
 	var datagridHeight=$("#jfa-content").height()-80;
 	$('#turnoverVehicle').bootstrapTable({
        url: '#(ctx)/admin/vehicleHistory/locationDetailList',
        method: 'get',
        toolbar: '#toolbar',
        striped: true,
        cache: false,
        pagination: false,
        sortable: false,                    
        sortOrder: "asc",  
        queryParams: function (params) {
	            var data = { 
	                    pageSize: params.limit,
	                    offset: params.offset,
					    'barcode': '#(barcode)'
	            };
	            return data;
        },
        sidePagination: "server",
        pageNumber:1,
        toolbarAlign:"right",
        pageSize:210,         
        pageList: [210, 420,100],
        search: false,
        strictSearch: true,
        showColumns: false,
        showRefresh: false,             
        minimumCountColumns: 2,
        clickToSelect: true,               
       	height: datagridHeight,
        uniqueId: "id",
        showToggle:false,
        cardView: false,
        detailView: false,
        rowStyle:rowStyler,
        columns: [
            {
                field: 'parameter_name',  title: '工艺名称'
            }, {
                field: 'errorStatus',  title: '合格状态',formatter:errorStatusFormatter
            }, {
                field: 'parameter_control_flag',  title: '启用参数控制',formatter:parameterControlFormatter
            }, {
				title: '参数设置范围',formatter:parameterAreaFormatter
            }, {
                field: 'parameter_min_value',  title: '参数最小值'
            }, {
                field: 'parameter_max_value',  title: '参数最大值'
            },{
            	field: 'stay_time_control_flag',  title: '启用时间控制',formatter:parameterControlFormatter
            },{
                title: '停留时间设置范围',formatter:stayTimeAreaFormatter
            },{
                field: 'realStayTime',  title: '实际停留时间（秒）'
			}
        ]
    });

function errorStatusFormatter(value,row,index) {
    switch(value){
		case 0:
		   return "合格";
		case 1:
		    return "参数不合格";
		case 2:
		    return "停留时间不合格";
		default:
		    return "";
	}
}
function stayTimeAreaFormatter(value, row, index){
	return row.min_stay_time + " -- "+row.max_stay_time
}
	
function searchVehicle(){
	$('#turnoverVehicle').bootstrapTable("refresh",{silent: true});
    layer.msg('操作成功');
}

function deleteVehicle(id){
	layer.confirm("确认删除该记录？", {
		icon: 0
		, title:'' 
		, shade: 0.4
		, offset: "139px"
	}, function(index) { 
		$.ajax({
			url:"#(ctx)/admin/turnoverVehicle/delete",
			data:{"id":id},
			dataType:"json",
			success:function(ret){
				$('#turnoverVehicle').bootstrapTable("refresh",{silent: true});
			    layer.msg(ret.msg);
			    layer.close(index);   
			},
			error:function(){
				layer.close(index);   
			}
		});                           
		                       
	});
}

function parameterControlFormatter(value, row, index) {
    if(value == 0){
        return "不启用"
	}else{
        return "启用"
	}
}
	

function parameterAreaFormatter(value, row, index) {
	return row.parameter_min_value_config + " -- "+row.parameter_max_value_config;
}

    function rowStyler(row, index){
            if(row.errorStatus != 0){
           		 return {css:{"background-color":"#d2691e"}}
        	}else{
                return {css:{"background-color":"#F9F9F9"}}
			}
    }

</script>
#end
